package xyz.chaoslolomonica.basic;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class Example1 {

	public static void main(String[] args) {
		String connectionString = "127.0.0.1:2181";

		try (CuratorFramework client = createSimpleClient(connectionString)) {
			client.start();
			client.create().creatingParentsIfNeeded().forPath("/haha", "test".getBytes());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static CuratorFramework createSimpleClient(String connectionString) {
		ExponentialBackoffRetry backoffRetry = new ExponentialBackoffRetry(1000, 3);
		return CuratorFrameworkFactory.newClient(connectionString, backoffRetry);
	}
}
